package com.example.springboot.controller;

import com.example.springboot.common.Result;
import com.example.springboot.entity.LocaleInfo;
import com.example.springboot.service.LocaleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 地点api
 */
@RestController
@RequestMapping("/locale")
@RequiredArgsConstructor
public class LocaleController {
    private final LocaleService localeService;

    @PostMapping("api/save")
    public Result saveLocale(@RequestBody LocaleInfo localeInfo){
        localeInfo.insertOrUpdate();
        return Result.success(localeInfo);
    }

    @PostMapping("api/del/{id}")
    public Result delLocale(@PathVariable Integer id){
        new LocaleInfo().deleteById(id);
        return Result.success();
    }

    @GetMapping("list")
    public Result delLocale(LocaleInfo localeInfo){
        /*LambdaQueryWrapper<LocaleInfo> wrapper = Wrappers.lambdaQuery(localeInfo);
        List<LocaleInfo> localeInfoList = localeInfo.selectList(wrapper);*/
        List<LocaleInfo> localeInfoList = localeService.listLocaleInfo(localeInfo);
        return Result.success(localeInfoList);
    }
}
